home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / AvantBrowser / asetup.exe / _data / webkit / chrome_100_percent.pak / Unnamed File 000019.txt < prev    next >
Text File  |  2013-04-03  |  2KB  |  75 lines

  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4.  
  5. // Custom bindings for the app API.
  6.  
  7. var appNatives = requireNative('app');
  8.  
  9. // This becomes chrome.app
  10. var app = {
  11.   getIsInstalled: appNatives.GetIsInstalled,
  12.   install: appNatives.Install,
  13.   getDetails: appNatives.GetDetails,
  14.   getDetailsForFrame: appNatives.GetDetailsForFrame,
  15.   runningState: appNatives.GetRunningState
  16. };
  17.  
  18. // Tricky; "getIsInstalled" is actually exposed as the getter "isInstalled",
  19. // but we don't have a way to express this in the schema JSON (nor is it
  20. // worth it for this one special case).
  21. //
  22. // So, define it manually, and let the getIsInstalled function act as its
  23. // documentation.
  24. app.__defineGetter__('isInstalled', appNatives.GetIsInstalled);
  25.  
  26. // Called by app_bindings.cc.
  27. // This becomes chromeHidden.app
  28. var chromeHiddenApp = {
  29.   onGetAppNotifyChannelResponse: function(channelId, error, callbackId) {
  30.     if (callbackId) {
  31.       callbacks[callbackId](channelId, error);
  32.       delete callbacks[callbackId];
  33.     }
  34.   },
  35.  
  36.   onInstallStateResponse: function(state, callbackId) {
  37.     if (callbackId) {
  38.       callbacks[callbackId](state);
  39.       delete callbacks[callbackId];
  40.     }
  41.   }
  42. };
  43.  
  44. // appNotification stuff.
  45. //
  46. // TODO(kalman): move this stuff to its own custom bindings.
  47. // It will be bit tricky since I'll need to look into why there are
  48. // permissions defined for app notifications, yet this always sets it up?
  49. var callbacks = {};
  50. var nextCallbackId = 1;
  51.  
  52. // This becomes chrome.appNotifications.
  53. var appNotifications = {
  54.   getChannel: function getChannel(clientId, callback) {
  55.     var callbackId = 0;
  56.     if (callback) {
  57.       callbackId = nextCallbackId++;
  58.       callbacks[callbackId] = callback;
  59.     }
  60.     appNatives.GetAppNotifyChannel(clientId, callbackId);
  61.   }
  62. };
  63.  
  64. app.installState = function getInstallState(callback) {
  65.   var callbackId = nextCallbackId++;
  66.   callbacks[callbackId] = callback;
  67.   appNatives.GetInstallState(callbackId);
  68. };
  69.  
  70. // These must match the names in InstallAppBindings() in
  71. // chrome/renderer/extensions/dispatcher.cc.
  72. exports.chromeApp = app;
  73. exports.chromeAppNotifications = appNotifications;
  74. exports.chromeHiddenApp = chromeHiddenApp;
  75.